App.require(function () {
    var app = App.getCurrent();

    app.definePage("addSceneObj", {
        render: function (next) {
            this.fetch("./index.html", function (text) {
                next(this.renderHTML(text));
            })
        },
        getDomObj: function () {
            this.attachDom(".btn-group", "btnGroup")
                .attachDom("#scenename", "sceneName")
                .attachDom("#description", "description")
                .attachEvent("btnGroup", "btnclick", this.btnClickHandler, false);
        },
        btnClickHandler: function (ev) {
            var component = ev.detail.component;
            switch (component.dataset.action) {
                case "cancel": this.parent.hidden(); break;
                case "sure": 
                    var sceneName = this.domList.sceneName.value;
                    var description = this.domList.description.value;
                    this.parent.parent.dispatchEvent("addSceneByName", {
                        name: sceneName,
                        description: description,
                        popup: this.parent
                    })
                    break;
            }
        }
    })
})